<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script src="./正则.js"></script>
  <script>
    // const reg1 = /^a/g;
    // const str1 = "abc\nabc"
    // const result1 = str1.match(reg1)
    // console.log(result1)

    // const reg2 = /\b/g
    // const str2 = "abc de fg"
    // const result2 = str2.match(reg2)
    // console.log(result2) //Array(6)

    // const reg3 = /\t/g

    // const str3 = "ab  c"
    // const result3 = str3.match(reg3)
    // console.log(result3) // null

    // const str4 = "ab\tc"
    // const result4 = str4.match(reg3)
    // console.log(result4) // ['\t']

    // const reg5 = /ab/g
    // const str5 = 'ababab'
    // console.log(reg5.lastIndex) // 0
    // console.log(reg5.exec(str5)) // ['ab', index: 0, input: 'ababab', groups: undefined]
    // console.log(reg5.lastIndex) // 2
    // console.log(reg5.exec(str5)) // ['ab', index: 2, input: 'ababab', groups: undefined]
    // console.log(reg5.lastIndex) // 4
    // console.log(reg5.exec(str5)) // ['ab', index: 4, input: 'ababab', groups: undefined]
    // console.log(reg5.lastIndex) // 6
    // console.log(reg5.exec(str5)) // null
    // console.log(reg5.lastIndex) // 0
    // console.log(reg5.exec(str5)) // ['ab', index: 0, input: 'ababab', groups: undefined]

    // const reg6 = /cd$/
    // const str6 = 'abcd'
    // console.log(str6.search(reg6)) // 2

    // const reg = /(\w)\1(\w)\2/g
    // const str = "aabb"
    // const result = str.replace(reg, "$2$2$1$1")
    // console.log(result) // bbaa

    // const reg = /-(\w)/g
    // const str = 'the-first-name'
    // const result = str.replace(reg, function ($, $1) {
    //   return $1.toUpperCase()
    // })
    // console.log(result) // theFirstName

    // const reg = /(\w)\1*/g
    // const str = "aaaaaabbbbbbccccccc"
    // const result = str.replace(reg, "$1")
    // console.log(result) // abc

    const reg = /(?=(\B)(\d{3})+$)/g
    const str = "1000000000"
    const result = str.replace(reg, ".")
    console.log(result)
  </script>
</body>

</html>